#include<iostream>
using namespace std;




int main()
{
    int arr[20]= {12, 23, 34, 45, 56, 67, 78, 89, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200};

    int key = 56;
    int left = 0 ,right = 19;

    while (left <= right)   
    {
        int mid = (left + right) / 2;

        if (key == arr[mid])
        {
            cout << "找到元素下标" << mid << endl;
            break;
        }

        else if (key > arr[mid])
        {
            left = mid + 1;
        }

        else
        {
            right = mid - 1;
        }
    }
    if (right < left)   
    {
        cout << "未找到元素" << endl;
    }
    
    
    
    return 0;
}
